<template>
    <div>
        <el-radio-group v-model="radio1" size="medium ">
            <el-radio-button label="派发管理中心"></el-radio-button>
            <el-radio-button label="处理"></el-radio-button>
            <el-radio-button label="其他"></el-radio-button>
            <!-- 0中心处理1路网审核2处理完成3处理失败4处理不了提交路网 -->
        </el-radio-group>

        <div style="margin-top:40px" v-if="radio1 == '派发管理中心'">
            <el-form ref="form1" :model="form1" :rules="rules1">
                <el-row :gutter="10">
                    <el-col :span="12">
                        <el-form-item prop="value">
                            <el-select v-model="form1.value" placeholder="请选择">
                                <el-option v-for="item in managementCenter" :key="item.id" :label="item.nickname" :value="item.id">
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row type="flex" justify="center" style="margin-top:40px">
                    <el-button type="primary" icon="el-icon-check" @click="wancheng">完成</el-button>
                </el-row>
            </el-form>
        </div>

        <div style="margin-top:40px" v-if="radio1 == '处理'">
            <el-form :model="form2" ref="form2" :rules="rules2">
                <el-row :gutter="10">
                    <el-col :span="24">
                        <div>上传图片：</div>
                    </el-col>
                    <el-col :span="24">
                        <el-form-item prop="replyImg">
                            <el-upload-image v-model="form2.replyImg" :limit="5"></el-upload-image>
                        </el-form-item>
                    </el-col>
                    <el-col :span="13">
                        <div>备注：</div>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item prop="reply">
                            <el-input type="textarea" rows="5" v-model="form2.reply"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row type="flex" justify="center" style="margin-top:40px">
                    <el-button type="primary" icon="el-icon-check" @click="aduit">完成</el-button>
                </el-row>
            </el-form>

        </div>

        <div style="margin-top:40px" v-if="radio1 == '其他'">
            <el-form :model="form3" ref="form3" :rules="rules3">
                <el-row :gutter="10">
                    <el-col :span="13">
                        <div> 备注：</div>
                    </el-col>
                    <el-col :span="12" style="margin-top:20px">
                        <el-form-item prop="failure">
                            <el-input type="textarea" rows="5" v-model="form3.failure"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row type="flex" justify="center" style="margin-top:40px">
                    <el-button type="primary" icon="el-icon-check" @click="other">完成</el-button>
                </el-row>
            </el-form>
        </div>
    </div>
</template>

<script>
import { post } from '@/assets/js/http';

export default {
    components: {
        "el-upload-image": () => import("@/components/el-upload-image.vue")
    },
    props: {
        managementCenter: {
            type: Array,
            default: () => []
        },
        rowData: {
            type: Object,
            default: () => { }
        }
    },
    data() {
        return {
            radio1: "派发管理中心",
            form1: {
                value: ""
            },
            form2: {
                replyImg: [],
                reply: "",
            },
            form3: {
                failure: "",
            },
            rules1: {
                value: [
                    { required: true, message: '请选择管理中心', trigger: 'change' }
                ]
            },
            rules2: {
                replyImg: [
                    { required: true, message: '请选择上传图片', trigger: 'change' }
                ],
                reply: [
                    { required: true, message: '请输入原由', trigger: 'blur' }
                ]
            },
            rules3: {
                failure: [
                    { required: true, message: '请输入原由', trigger: 'blur' }
                ]
            }
        }
    },

    methods: {
        //派发管理中心
        wancheng() {
            this.$refs.form1.validate((valid) => {
                if (valid) {
                    post({
                        url: "/admin/answer.Subject/road_work",
                        data: {
                            id: this.rowData.id,
                            cl_status: 0,//0中心处理1路网审核2处理完成3处理失败4处理不了提交路网
                            g_admin_id: this.form1.value,

                        },
                        successTip: true,
                        loading: true
                    }).finally(() => {
                        this.$emit("closePopover", false)
                    })
                }
            })
        },
        //处理
        aduit() {
            let imgs = this.form2.replyImg.map(i => i.url)
            imgs = imgs.join("|")
            this.$refs.form2.validate((valid) => {
                if (valid) {
                    post({
                        url: "/admin/answer.Subject/road_work",
                        data: {
                            id: this.rowData.id,
                            cl_status: 2,//0中心处理1路网审核2处理完成3处理失败4处理不了提交路网
                            reply: this.form2.reply,
                            reply_img: imgs
                        },
                        loading: true,
                        successTip: true

                    }).finally(() => {
                        this.$emit("closePopover", false)

                    })
                }
            })

        },
        //其他
        other() {
            this.$refs.form3.validate((valid) => {
                if (valid) {
                    post({
                        url: "/admin/answer.Subject/road_work",
                        data: {
                            id: this.rowData.id,
                            cl_status: 3,//0中心处理1路网审核2处理完成3处理失败4处理不了提交路网
                            reply: this.form3.failure
                        },
                        loading: true,
                        successTip: true

                    }).finally(() => {
                        this.$emit("closePopover", false)
                    })
                }
            })
        }
    },
    mounted() {
        if (this.rowData.l_admin_id != 0) {
            this.form1.value = this.rowData.l_admin_id
        }
    }
}
</script>

<style></style>